<!-- Created by jack on 2022/3/17 - 15:35 -->
<style>
@keyframes start {
  from{
    transform: scale(1.5);
    opacity: 0;
  }
  to{
    transform: scale(1);
    backdrop-filter: blur(10px);
    opacity: 1;
  }
}
.start{
  animation: start 500ms 0s ease-in-out 1 forwards;
}
.out{
  animation: start 500ms 0s ease-in-out 1 forwards reverse;
}
</style>
<style scoped lang="less">
.main{
  user-select: none;
  top: 0;
  left: 0;
  width: 100vw;
  height:  100vh;
  position: absolute;
  z-index: 19999;
  box-sizing: border-box;
  color: white;
  .content{
    width: 100%;
    height: 100%;
    content: '';
    left: 0;
    top: 0;
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: column;
  }
  &::after{
    width: 100%;
    height: 100%;
    content: '';
    left: 0;
    top: 0;
    position: absolute;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1;
  }
  &__header{
    width: 100%;
    height: 150px;
  }
  &__grid{
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 0 100px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 200px);
    grid-template-rows: repeat(auto-fill, 160px);
    justify-content: center;
    box-sizing: border-box;
    grid-gap: 30px;
    &__app{
      display: flex;
      flex-direction: column;
      align-items: center;
      //justify-content: center
      &__icon{
        border-radius: 20px;
        width: 100px;
        height: 100px;
        &:hover{
          background: rgba(215, 218, 225, 0.37);
          box-shadow: 0 0 20px 3px rgba(0, 0, 0, 0.11);
        }
        &:active{
          opacity: 0.6;
        }
      }
      &__name{
        text-align: center;
      }
    }
  }
  &__footer{
    width: 100%;
    height: 200px;
  }
}
</style>

<template>
<div class="main start" id="launchPad">
  <div class="content">
    <div class="main__header"></div>
    <div class="main__grid">
      <div class="main__grid__app" draggable="true" v-for="(ele,index) of appList" :key="ele.name">
        <img :src="ele.logo" class="main__grid__app__icon" @click="clickAppIcon(ele)">
        <div class="main__grid__app__name">{{ ele.name }}</div>
      </div>
    </div>
    <div class="main__footer"></div>
  </div>
</div>
</template>

<script lang="ts" setup>
import {computed} from "vue";
import mainStore from "@/store/main";
import {removeObjectKey, setTimer} from "@/helper";

// 应用列表
const appList = computed(_ => removeObjectKey(mainStore.$state.applications,'launchPad'))

/** 关闭应用 */
const close = () => {
  document.getElementById('launchPad')?.classList.add('out')
  setTimer(() => {
    document.getElementById('launchPad')?.remove()
  },500,1)
}
// 点击应用
const clickAppIcon = (event:any) => {
  const { run } = event
  run()
  close()
}
</script>
